package com.itheima.servlet;

import com.itheima.domain.User;
import com.itheima.utils.MapperUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class DemoCondition {
    @Test
    public void test2(){
        //1.工具类获取session
        SqlSession session = MapperUtils.getSqlSession();
        User u = new User();
        u.setId(5);
        u.setName("文若");
        u.setCountry("魏");
        session.update("com.itheima.mapper.UserMapper.updateUser", u);
        //2.关闭session
        MapperUtils.close(session);
    }





    @Test
    public void test1(){
        //1.工具类获取session
        SqlSession session = MapperUtils.getSqlSession();
//        List list1 = new ArrayList();
//        list1.add(1);
        String []arr = {"a","b","c"};

        //可能有多条记录的使用selectList()
        List<User> list = session.selectList("com.itheima.mapper.UserMapper.findCondition",arr);
        //System.out.println(list.size());
        //2.关闭session
        MapperUtils.close(session);
    }
}
